package com.dgshanger.sanhxiaofeisc.mvp.model;

import com.blankj.utilcode.util.EncryptUtils;
import com.dgshanger.sanhxiaofeisc.common.AppApi;
import com.dgshanger.sanhxiaofeisc.entity.CheckPwdEntity;
import com.dgshanger.sanhxiaofeisc.entity.TransferAccountsEntity;
import com.dgshanger.sanhxiaofeisc.entity.UserEntity;
import com.dgshanger.sanhxiaofeisc.mvp.contract.TransferAccountsContract;
import com.xx.baseutilslibrary.network.rx.RxHelper;
import com.xx.baseutilslibrary.network.rx.RxHttpObserver;

/**
 * TransferAccountsModel
 * 沉迷学习不能自拔
 * Describe：
 * Created by 雷小星🍀 on 2018/5/3 15:51.
 */

public class TransferAccountsModel implements TransferAccountsContract.Model {
    @Override
    public void loadData(RxHttpObserver<TransferAccountsEntity> httpObserver) {
        AppApi.Api()
                .transfer_detail()
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }

    @Override
    public void loadUser(String user_mobile, RxHttpObserver<UserEntity> httpObserver) {
        AppApi.Api()
                .user_by_mobile(user_mobile)
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }

    @Override
    public void transfer(String payee_user_mobile, String wallet_money, String integral_number, String remark, String user_pay_pwd, RxHttpObserver<Object> httpObserver) {
        AppApi.Api()
                .transfer(payee_user_mobile, wallet_money, integral_number, remark, EncryptUtils.encryptMD5ToString(user_pay_pwd).toLowerCase())
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }

    @Override
    public void checkPayPwd(RxHttpObserver<CheckPwdEntity> httpObserver) {
        AppApi.Api().checkPwd()
                .compose(RxHelper.io_main())
                .subscribe(httpObserver);
    }
}
